<?php
/* SVN FILE: $Id: statistics_season_players_controller.php 250 2010-06-17 10:55:41Z gregory.rome $ */
/**
 * StatisticsSeasonPlayers Controller.
 *
 * cBBweb : Digital Blood Bowl league interface (http://code.google.com/p/cbbweb/)
 * Copyright 2009-2010, Grégory Romé.
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright     Copyright 2009-2010, Grégory Romé.
 * @link          http://code.google.com/p/cbbweb/ cBBweb Project
 * @package       cbbweb
 * @subpackage    cbbweb.controllers
 * @version       $Revision: 250 $
 * @modifiedby    $LastChangedBy: gregory.rome $
 * @lastmodified  $Date: 2010-06-17 10:55:41 +0000 (Thu, 17 Jun 2010) $
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 */

/**
 * StatisticsSeasonPlayers Controller.
 *
 * @package       cbbweb
 * @subpackage    cbbweb.controllers
 */
class StatisticsSeasonPlayersController extends AppController {

	var $name = 'StatisticsSeasonPlayers';
  var $paginate = array(
  	'StatisticsSeasonPlayer' => array(
  		'order' => array(
				'StatisticsSeasonPlayer.Inflicted_iTouchdowns' => 'desc',
				'Player.iExperience' => 'desc',
				'Player.iValue' => 'desc'),
			'limit' => 10,
  		'contain' => array(
				'Player' => array(
					'fields' => array(
						'Player.ID',
						'Player.strName',
						'Player.idTeam_Listing',
						'Player.iValue',
						'Player.iExperience'),
					'Team' => array(
						'fields' => array('Team.ID, Team.strName')
					)
				)
			)
  ));

	function index() {
		if (!$this->championship) {
			$this->Session->setFlash(__('You must select a championship', true));
			$this->set('noview', true);
			return;
		} else {
			$this->set('noview', false);
			$championship = $this->StatisticsSeasonPlayer->Championship->read(null, $this->championship);

			$statisticsSeasonPlayers = $this->paginate('StatisticsSeasonPlayer', array(
				'StatisticsSeasonPlayer.idRule_Listing' => $this->championship,
				'StatisticsSeasonPlayer.iSeason' => $championship['Championship']['iSeason']
			));

			$this->set('statisticsSeasonPlayers', $statisticsSeasonPlayers);
		}
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid StatisticsSeasonPlayer', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('statisticsSeasonPlayer', $this->StatisticsSeasonPlayer->read(null, $id));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for StatisticsSeasonPlayer', true));
			$this->redirect(array('action' => 'index'));
		}
		if ($this->StatisticsSeasonPlayer->del($id)) {
			$this->Session->setFlash(__('StatisticsSeasonPlayer deleted', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->Session->setFlash(__('The StatisticsSeasonPlayer could not be deleted. Please, try again.', true));
		$this->redirect(array('action' => 'index'));
	}

}
?>